<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('解压文件管理列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="product:ncUnzip:remove">
                <i class="fa fa-remove"></i> 批量删除
            </a>
            <a class="btn btn-success multiple disabled" onclick="removeAllCompeletly()" shiro:hasPermission="product:ncUnzip:removeCompletely">
                <i class="fa fa-plus"></i> 批量彻底删除
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var removeFlag = [[${@permission.hasPermi('product:ncUnzip:remove')}]];
    var removeCompletelyFlag = [[${@permission.hasPermi('product:ncUnzip:removeCompletely')}]];
    var prefix = ctx + "product/ncUnzip";

    var del = [[${@dict.getType('yes_or_no')}]];

    $(function() {
        var options = {
            url: prefix + "/list",
            removeUrl: prefix + "/remove",
            removeCompeletlyUrl: prefix + "/removeCompeletly",
            modalName: "解压文件管理",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'id',
                    visible: false,
                    ignore: true
                },
                {
                    field: 'filePath',
                    title: '文件路径',
                },
                {
                    field: 'fileName',
                    title: '文件名称',
                },
                {
                    field: 'fileSize',
                    title: '文件大小',
                },
                {
                    field: 'del',
                    title: '是否删除',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(del,value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-default btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa "></i>删除</a>');
                        actions.push('<a class="btn btn-default btn-xs ' + removeCompletelyFlag + '" href="javascript:void(0)" onclick="removeCompeletly(\'' + row.id + '\')"><i class="fa "></i>彻底删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function removeCompeletly(id) {
        table.set();
        $.modal.confirm("确定彻底删除该条" + table.options.modalName + "信息吗？", function() {
            var url = $.common.isEmpty(id) ? table.options.removeCompeletlyUrl : table.options.removeCompeletlyUrl.replace("{id}", id);
            if (table.options.type == table_type.bootstrapTreeTable) {
                $.operate.get(url);
            } else {
                var data = { "ids": id };
                $.operate.submit(url, "post", "json", data);
            }
        });
    }

    function removeAllCompeletly() {
        table.set();
        var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        $.modal.confirm("确认要批量彻底删除选中的" + rows.length + "条数据吗?", function() {
            var url = table.options.removeCompeletlyUrl;
            var data = { "ids": rows.join() };
            $.operate.submit(url, "post", "json", data);
        });
    }
</script>
</body>
</html>
